You are here: Resources > Performance Tips > Temporary Variables

Temporary Variables

When writing actions, you can reduce the amount of repeated processing within aggregate values or loops by storing computed values as temporary values.

A loop could be existence, for all or chaining conditions, as well as while loops or loop over objects operations.

If each iteration of the loop is performing some non-trivial work on the current object such as buffering, then it is quicker to perform the buffering once, assign the result to a temporary value and then use the temporary value within the loop.

The For all loop displayed in the action below will calculate the buffer of the current Centre-Line object for every iteration, even though the result will be identical each time.

Buffering occurs for every iteration of the loop

The action below will be faster, as the buffer is calculated only once, stored as a temporary variable and then the temporary variable is used within the loop.

Buffer is calculated only once